package com.hou.shop.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.hou.common.valid.AddGroup;
import com.hou.common.valid.ListValue;
import com.hou.common.valid.UpdateGroup;
import com.hou.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *
 * @author houzongdu
 * @email 1716532921@qq.com
 * @date 2022-01-16 16:38:38
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    // 添加验证：id不能为空
    // 修改验证：不能输入id值
    @Null(message = "新增id不能为空", groups = AddGroup.class)
    @NotNull(message = "不能修改id", groups = UpdateGroup.class)
    @TableId
    private Long brandId;
    /**
     * 品牌名
     */
    // 添加修改验证：品牌名不能为空
    @NotBlank(message = "品牌名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String name;
    /**
     * 品牌logo地址
     */
    // 添加、修改验证：logo地址不能为空、logo地址需要合法
    @NotEmpty(message = "必须输入logo地址", groups = {AddGroup.class, UpdateGroup.class})
    @URL(message = "logo需为合法地址", groups = {UpdateGroup.class, AddGroup.class})
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @NotNull(groups = {AddGroup.class,UpdateStatusGroup.class})
    @ListValue(vals = {0,1},groups = {AddGroup.class, UpdateStatusGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    // 添加、修改验证：不能为空，必须是一个字母
    @NotEmpty(message = "字母不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须为一个字母", groups = {AddGroup.class, UpdateGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    // 添加、修改验证：必须有排序值、排序值必须为合法数字
    @NotNull(message = "排序必须有值", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 0, message = "排序必须大于等于零", groups = {AddGroup.class, UpdateGroup.class})
    private Integer sort;

}
